Skip to content

HIVE-28400: Refactor QueryProperties feature flags to use QueryFeature enum#6560

Open
Manya0407 wants to merge 1 commit into
apache:masterfrom
Manya0407:refactor_queryproperties
Open

HIVE-28400: Refactor QueryProperties feature flags to use QueryFeature enum#6560
Manya0407 wants to merge 1 commit into
apache:masterfrom
Manya0407:refactor_queryproperties

Conversation

@Manya0407

@Manya0407 Manya0407 commented Jun 24, 2026

Copy link
Copy Markdown
Contributor

What changes were proposed in this pull request?

1.This PR refactors QueryProperties feature tracking from multiple boolean fields to an enum-based model.
2.Query feature flags such as GROUP_BY, ORDER_BY, LIMIT, PTF, WINDOWING, QUALIFY, EXCEPT, INTERSECT, USES_SCRIPT, and related clause flags are now represented by QueryFeature values stored in an EnumSet<QueryFeature>.
3.Relevant feature writer and reader call sites were updated to use addFeature(QueryFeature.X) and hasFeature(QueryFeature.X).
4.Compatibility wrapper methods such as hasGroupBy() and setHasGroupBy(boolean) continue to delegate to the enum-backed storage. Non-feature state such as join counts, query type, lateral view flags, view/materialized view flags, analyze flags, and used tables remains unchanged.

Why are the changes needed?

The previous implementation stored query features as many individual boolean fields, which made QueryProperties harder to read and extend.Using a QueryFeature enum with EnumSet keeps related feature state in one place, reduces repeated boolean field management, and makes adding future query features simpler and less error-prone.EnumSet is also efficient for enum values and is a good fit for representing query features.

Does this PR introduce any user-facing change?

No

How was this patch tested?

Manual testing

@Manya0407 Manya0407 changed the title Refactor QueryProperties feature flags to use QueryFeature enum HIVE-28400: Refactor QueryProperties feature flags to use QueryFeature enum Jun 24, 2026
@sonarqubecloud

Copy link
Copy Markdown

@ayushtkn ayushtkn left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanx @Manya0407, Changes LGTM.

The original ticket was from @zabetak , Will be good to get his blessing as well. I am even thinking should we deprecate the individual methods and recommend using the new one quoting these individual methods will be dropped in the subsequent release

@abstractdog abstractdog self-requested a review June 26, 2026 07:15

@abstractdog abstractdog left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

left minor comments
I found it hard to decide which boolean fields fall into the "feature" category and which don't, now I feel all of them are features except the basic ones like

  boolean query;
  boolean analyzeCommand;
  boolean noScanAnalyzeCommand;
  boolean analyzeRewrite;
  boolean ctas;

Comment on lines 89 to 90
private boolean hasLateralViews = false;
private boolean cboSupportedLateralViews = true;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these seem to be features too

return features.contains(feature);
}

public boolean hasGroupBy() {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the jira description says "the class is unnecessarily verbose since each feature requires a dedicated getter/setter"
I feel we can go on with removing these without deprecation

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, it would be nice to get rid of the setters/getters. It's a rather internal class so I don't think we need to deprecate first.

Comment on lines 95 to 96
private boolean multiDestQuery;
private boolean filterWithSubQuery;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these seem to be features too

Comment on lines 99 to 100
private boolean isMaterializedView;
private boolean isView;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these seem to be features too

return features.contains(feature);
}

public boolean hasGroupBy() {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, it would be nice to get rid of the setters/getters. It's a rather internal class so I don't think we need to deprecate first.

boolean hasDistributeBy = false;
boolean hasClusterBy = false;
private final EnumSet<QueryFeature> features = EnumSet.noneOf(QueryFeature.class);
boolean mapJoinRemoved = false;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems to be unused so it can be dropped; it is set but never queried/accessed. Check if there are other unused feature/flags and remove them as well.

Comment on lines 79 to 82
boolean analyzeCommand;
boolean noScanAnalyzeCommand;
boolean analyzeRewrite;
boolean ctas;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would put CTAS, and ANALYZE as feature as wells. For the mutliple analyze variants maybe we could use multiple enum entries:
analyzeCommand -> QueryFeature.ANALYZE
noScanAnalyze -> QueryFeature.ANALYZE + QueryFeature.NO_SCAN
analyzeRewrite -> QueryFeature.ANALYZE + QueryFeature.REWRITE

boolean ctas;
int outerQueryLimit;

boolean hasJoin = false;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feature as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants